//
//  DocReviewViewController.m
//  lsOA
//
//  Created by 蓝水软件 on 16/7/22.
//  Copyright © 2016年 苏州蓝水有限公司. All rights reserved.
//

#import "DocReviewViewController.h"


@interface DocReviewViewController ()<UIWebViewDelegate,UITextFieldDelegate,UITableViewDelegate,UITableViewDataSource>
{
    UIView *under;
    UIView *under2 ;
    UIView *under3;
    UIView *under5;
    UIView *under6;
    UILabel *approval;  //标签: 审批操作
    UILabel *label; //标题
    UIButton *agreeButton;  //我批准
    UIButton *dissAgree;  //我不同意
    LeftTitleTextField *issuanceState; //签发状态
    LeftTitleTextField *drafter;   //拟稿人员
    LeftTitleTextField *drafteData;    //拟稿日期
    LeftTitleTextField *currentLink;   //当前环节
    UILabel *approver;  //标题 审批者
    UILabel *approverContent;   //审批人员
    LeftTitleTextField *secretLevel;    //保密等级
    UITextView *instructions;  //公文说明
    UILabel *OpinionList;    //审核意见列表
    UIWebView *webViewZQX; //浏览器
    UITextField *myOpinion; //我的意见
    NSString *stringFromUtf;    //意见列表
    UIScrollView *scrollView;
    UITapGestureRecognizer *tapGecognizer;// 单击手势 用来响应编辑 改变文本框位置
    UITableView *otherContenTableView; //表格
    UIButton *showContentButton;    //查看全文
    
    
    
}
@end

@implementation DocReviewViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self getData];
    
}

- (void)setValue{
    self.title = self.dic[@"TypeName"];
    label.text = self.dic[@"Flow_Name"];
    //    状态(-1已退回0审批中1已完成2已过期)
    switch ([self.dic[@"Status"] integerValue]) {
        case -1:{
            issuanceState.text = @"已退回";
        }
            break;
        case 0:{
            issuanceState.text = @"审批中";
        }
            break;
        case 1:{
            issuanceState.text = @"已完成";
        }
            break;
        case 2:{
            issuanceState.text = @"已过期";
        }
            break;
        default:{
            issuanceState.text = @"未知状态";
        }
            break;
    }
    drafter.text = self.dataFromAFNet[@"CreatorRealName"];
    drafteData.text = self.dataFromAFNet[@"AddTime"];
    currentLink.text = self.dataFromAFNet[@"CurrentStepName"];
    approver.text = [NSString stringWithFormat:@"当前审批者:   %@",self.dataFromAFNet[@"CurrentStepUserName"]];
    approver.numberOfLines = 0;
    [approver sizeToFit];
    [under mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(approver.mas_bottom).offset(10);
    }];
    
    instructions.text = self.dataFromAFNet[@"Remark"];
    OpinionList.text = stringFromUtf;
    [OpinionList sizeToFit];
    [under5 mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(OpinionList.mas_bottom).offset(5);
    }];
    
    if ([self.dataFromAFNet[@"notDeal"] isEqualToString:@"0"]) {
        [agreeButton mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
        [dissAgree mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
        [approval mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
        [myOpinion mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
        myOpinion.placeholder = @"";
        [under6 mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
        [agreeButton setTitle:@"" forState:UIControlStateNormal];
        [dissAgree setTitle:@"" forState:UIControlStateNormal];
    }else{
        
        
    }
}

- (void)getData{
    [self getFotData];
    
}

- (void)getDataDetail{
    NSString *ashx = @"/Server/FlowsHandler.ashx";
    [GMDCircleLoader setOnView:self.view withTitle:@"加载中" animated:YES];
    NSDictionary *dic = @{@"act":@"getfdetail",@"fid":self.dic[@"ID"],@"uname":[UserInfo getUserName],@"upwd":[UserInfo getPassWord]};
    [httpPostRequest getDataByPostAshx:ashx and:dic withFinishBlock:^(id model, NSError *error) {
        [GMDCircleLoader hideFromView:self.view animated:YES];
        if (error == nil) {
            NSString *code = [NSString stringWithFormat:@"%@",[model objectForKey:@"code"]];
            if ([code isEqualToString:@"0"]) {
                
                NSLog(@"公文审批:%@",model);
                self.dataFromAFNet = model[@"data"][0];
                NSString *YjList = model[@"data"][0][@"YjList"];
                stringFromUtf = [YjList stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                [self setUI];
                [self setValue];
            }else{
                [XHToast showCenterWithText:[model objectForKey:@"msg"]];
            }
        }else{
            [GMDCircleLoader hideFromView:self.view animated:YES];
            NSLog(@"错误%@",error);
            [XHToast showBottomWithText:@"请求失败"];
        }
    }];
    
}

//获取额外内容
- (void)getFotData{
    NSString *ashx = @"/Server/FlowsHandler.ashx";
    [GMDCircleLoader setOnView:self.view withTitle:@"加载中" animated:YES];
    NSDictionary *getfotDic = @{@"act":@"getfot",@"fid":self.dic[@"ID"],@"uname":[UserInfo getUserName],@"upwd":[UserInfo getPassWord]};
    [httpPostRequest getDataByPostAshx:ashx and:getfotDic withFinishBlock:^(id model, NSError *error) {
        [GMDCircleLoader hideFromView:self.view animated:YES];
        if (error == nil) {
            NSString *code = [NSString stringWithFormat:@"%@",[model objectForKey:@"code"]];
            if ([code isEqualToString:@"0"]) {
                NSLog(@"额外内容：%@",model);
                NSArray *dataArray = [model objectForKey:@"data"];
                //如果额外内容有数据 就执行
                if (dataArray.count > 0) {
               
                   self.otherConteDataSource = [self detailWithArray:dataArray];
                    
                }
                [self getDataDetail];
            }else{
                [XHToast showCenterWithText:[model objectForKey:@"msg"]];
            }
        }else{
            [GMDCircleLoader hideFromView:self.view animated:YES];
            NSLog(@"错误%@",error);
            [XHToast showBottomWithText:@"请求失败"];
        }
    }];
}

//处理额外内容数据，将数据插入到一个二维数据,inRNum相同拼在同一组
- (NSMutableArray *) detailWithArray:(NSArray *)dataArray{
    int max = 0;
    NSMutableArray *otrherMutableArray = [NSMutableArray new];
    NSLog(@"dataArray:%@",dataArray);
    for (NSDictionary *dic in dataArray) {
        //便利数据 获取最大行数
        max = max > [[dic objectForKey:@"inRNum"] intValue]? max:[[dic objectForKey:@"inRNum"] intValue];
        NSLog(@"max:%ld",max);
    }

    for (int i = 1; i < max+1; i++) {
        
        NSMutableArray *tempMutableArray = [NSMutableArray array];
        
        for (NSDictionary *dic in dataArray) {
            
            if ([[dic objectForKey:@"inRNum"] intValue] == i) {
                
                [tempMutableArray insertObject:dic atIndex:[[dic objectForKey:@"inCNum"] intValue]-1];
                
            }
            
        }
        [otrherMutableArray addObject:tempMutableArray];
    }
    NSLog(@"处理后的数据:%@",otrherMutableArray);
    return otrherMutableArray;
}
- (void)setUI{
    WS(ws);
    scrollView = [[UIScrollView alloc]init];
    [self.view addSubview:scrollView];
    [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(ws.view).with.insets(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
    scrollView.bounces = YES;
    scrollView.scrollEnabled = YES;
    scrollView.scrollsToTop = NO;
    
    UIView *container = [UIView new];
    [scrollView addSubview:container];
    container.backgroundColor = [UIColor colorWithWhite:0.911 alpha:1.000];;
    [container mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(scrollView);
        make.edges.equalTo(scrollView).with.insets(UIEdgeInsetsMake(0,0,0,0));
    }];
    CGFloat height  = 30*FitSize;
    CGFloat width = 250*FitSize;
    UIColor *underColor = [UIColor colorWithWhite:0.050 alpha:1.000];
    /**
     *标题
     */
    label = [[UILabel alloc]init];
    NSString *titleContent = @"测试标题";
    label.text = titleContent;
    label.textAlignment = NSTextAlignmentCenter;
    [container addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(height);
    }];
    
    
    under = [[UIView alloc]init];
    under.backgroundColor = [UIColor whiteColor];
    [container addSubview:under];
    [under mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.top.equalTo(label.mas_bottom).offset(5);
    }];
    under.layer.cornerRadius = 10;
    
    issuanceState = [[LeftTitleTextField alloc]initWithUnderLineColor:underColor height:height width:width title:@"签发状态:"];
    [issuanceState hideUnderLine];
    [under addSubview:issuanceState];
    [issuanceState mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(5*FitSize);
        make.left.mas_equalTo(15*FitSize);
        make.right.mas_equalTo(-15*FitSize);
        make.height.mas_equalTo(height);
    }];
    
    
    drafter = [[LeftTitleTextField alloc]initWithUnderLineColor:underColor height:height width:width title:@"拟稿人员:"];
    [drafter hideUnderLine];
    [under addSubview:drafter];
    [drafter mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(issuanceState.mas_bottom).offset(5);
        make.left.mas_equalTo(15*FitSize);
        make.right.mas_equalTo(-15*FitSize);
        make.height.mas_equalTo(height);
    }];
    
    drafteData = [[LeftTitleTextField alloc]initWithUnderLineColor:underColor height:height width:width title:@"签发日期:"];
    [drafteData hideUnderLine];
    [under addSubview:drafteData];
    [drafteData mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(drafter.mas_bottom).offset(5);
        make.left.mas_equalTo(15*FitSize);
        make.right.mas_equalTo(-15*FitSize);
        make.height.mas_equalTo(height);
    }];
    
    currentLink = [[LeftTitleTextField alloc]initWithUnderLineColor:underColor height:height width:width title:@"当前环节:"];
    [currentLink hideUnderLine];
    [under addSubview:currentLink];
    [currentLink mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(drafteData.mas_bottom).offset(5);
        make.left.mas_equalTo(15*FitSize);
        make.right.mas_equalTo(-15*FitSize);
        make.height.mas_equalTo(height);
    }];
    
    approver = [[UILabel alloc]init];
    approver.textColor = [UIColor blackColor];
    [under addSubview:approver];
    [approver mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(currentLink.mas_bottom).offset(5);
        make.left.mas_equalTo(15*FitSize);
        make.right.mas_equalTo(-15*FitSize);
    }];
    

    UILabel *officialDoc = [UILabel new];
    [container addSubview:officialDoc];
    [officialDoc mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(under.mas_bottom).offset(30);
        make.centerX.equalTo(container);
        make.height.mas_equalTo(30);
    }];
    officialDoc.text = @"公文内容";
    
    //公文内容
    under2 = [[UIView alloc]init];
    [container addSubview:under2];
    [under2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(officialDoc.mas_bottom).offset(10);
        make.left.equalTo(under);
        make.right.equalTo(under);
        make.height.mas_equalTo(30);
    }];
    under2.layer.cornerRadius = 10;
    under2.backgroundColor = [UIColor whiteColor];
    
    

    webViewZQX = [[UIWebView alloc] init];
    webViewZQX.backgroundColor = [UIColor whiteColor];
    [webViewZQX setUserInteractionEnabled:NO];
    [(UIScrollView *)[[webViewZQX subviews] objectAtIndex:0] setBounces:NO];
    [webViewZQX setScalesPageToFit:YES];     //yes:根据webview自适应，NO：根据内容自适应
    [webViewZQX setDelegate:self];
    [under2 addSubview:webViewZQX];
    [webViewZQX mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10);
        make.left.mas_equalTo(1);
        make.right.mas_equalTo(-1);
        make.bottom.mas_equalTo(-10);
    }];
    
    showContentButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [under2 addSubview:showContentButton];
    [showContentButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(under2);
        make.size.mas_equalTo(CGSizeMake(100, 30));
    }];
    [showContentButton addTarget:self action:@selector(showContent) forControlEvents:UIControlEventTouchUpInside];
    [showContentButton setTitle:@"查看全文" forState:UIControlStateNormal];
    [showContentButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal ];
    
    //公文说明
    under3 = [[UIView alloc]init];
    [container addSubview:under3];
    [under3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(under2.mas_bottom).offset(20);
        make.left.equalTo(under);
        make.right.equalTo(under);
    }];
    under3.backgroundColor = [UIColor whiteColor];
    under3.layer.cornerRadius = 10;
    
    UILabel *instructionLabel = [UILabel new];
    instructionLabel.text = @"公文说明:";
    [under3 addSubview:instructionLabel];
    [instructionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(under3.mas_top).offset(5);
        make.left.mas_equalTo(under3.mas_left).offset(15);
        make.height.mas_equalTo(height);
    }];
    
    instructions = [UITextView new];
    [under3 addSubview:instructions];
    instructions.font = FONT(16);
    [instructions mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(instructionLabel.mas_bottom).offset(10);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(height);
    }];
    
    [under3 mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(instructions.mas_bottom).offset(5);
    }];
    
    UIView *under4 = [[UIView alloc]init];
    [container addSubview:under4];
    [under4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(under3.mas_bottom).offset(20);
        make.left.equalTo(under);
        make.right.equalTo(under);
        make.height.mas_equalTo(40);
    }];
    under4.backgroundColor = [UIColor whiteColor];
    under4.layer.cornerRadius = 10;
    
    
    UILabel *attachment = [[UILabel alloc]init];
    [under4 addSubview:attachment];
    [attachment mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(25);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(height);
        make.centerY.equalTo(under4);
    }];
    attachment.text = @"相关附件:";
    
    //审批意见
    under5 = [[UIView alloc]init];
    [container addSubview:under5];
    [under5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(under4.mas_bottom).offset(20);
        make.left.equalTo(under);
        make.right.equalTo(under);
        //        make.height.mas_equalTo(40);
    }];
    under5.backgroundColor = [UIColor whiteColor];
    under5.layer.cornerRadius = 10;
    
    UILabel *range = [[UILabel alloc]init];
    [under5 addSubview:range];
    [range mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(25);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(height);
        make.top.mas_equalTo(5);
    }];
    range.text = @"审批意见列表:";
    
    OpinionList = [[UILabel alloc]init];
    [under5 addSubview:OpinionList];
    OpinionList.numberOfLines = 0;
    [OpinionList sizeToFit];
    [OpinionList mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(range.mas_bottom).offset(10);
        make.left.equalTo(range);
        make.right.mas_equalTo(-15);
        
    }];
    
    [under5 mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(OpinionList.mas_bottom).offset(5);
    }];
    
    UIView *otherUnder  = [UIView new];
    [container addSubview:otherUnder];
    otherUnder.backgroundColor = [UIColor whiteColor];
    //判断额外内容是否有数据，没有高度就设置为0
    NSInteger otherHeight = 0;
    if (self.otherConteDataSource.count >0) {
        otherHeight = 120;
    }
    [otherUnder mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(under5.mas_bottom).offset(10);
        make.left.equalTo(under);
        make.right.equalTo(under);
        make.height.mas_equalTo(otherHeight);
    }];
    otherUnder.layer.cornerRadius = 10;
    
    otherContenTableView = [[UITableView alloc] init];
    otherContenTableView.delegate = self;
    otherContenTableView.dataSource = self;
    otherContenTableView.scrollsToTop = NO;
    [otherUnder addSubview:otherContenTableView];
    [otherContenTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(otherUnder).insets(UIEdgeInsetsMake(5, 3, 0, 3));
    }];
    
    
    under6 = [[UIView alloc]init];
    [container addSubview:under6];
    under6.backgroundColor = [UIColor whiteColor];
    [under6 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(otherUnder.mas_bottom).offset(20);
        make.left.equalTo(under);
        make.right.equalTo(under);
    }];
    under6.layer.cornerRadius = 10;
    
    approval = [[UILabel alloc]init];
    [under6 addSubview:approval];
    approval.text = @"审批操作:";
    [approval mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(under6.mas_top).offset(5);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-5);
        make.height.mas_equalTo(30*FitSize).priorityLow();
    }];
    
    myOpinion = [[UITextField alloc]init];
    [under6 addSubview:myOpinion];
    myOpinion.delegate = self;
    myOpinion.borderStyle = UITextBorderStyleLine;
    myOpinion.placeholder = @"请在这输入审批意见";
    myOpinion.layer.borderColor = [UIColor lightGrayColor].CGColor;
    [myOpinion mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(approval.mas_bottom).offset(10);
        make.left.mas_equalTo(5);
        make.right.mas_equalTo(-5);
        make.height.mas_equalTo(30*FitSize).priorityLow();
    }];
    
    agreeButton = [UIButton buttonWithType:UIButtonTypeSystem];
    agreeButton.tag = 900+1;
    [agreeButton setTitle:@"我要批准" forState:UIControlStateNormal];
    [agreeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    agreeButton.titleLabel.font = FONT(16);
    agreeButton.backgroundColor = [UIColor colorWithRed:0.322 green:0.566 blue:1.000 alpha:1.000];
    [agreeButton addTarget:self action:@selector(approval:) forControlEvents:UIControlEventTouchUpInside];
    [under6 addSubview:agreeButton];
    [agreeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(myOpinion.mas_bottom).offset(10);
        make.width.mas_equalTo(200*FitSize);
        make.height.mas_equalTo(30*FitSize).priorityLow();
        make.centerX.equalTo(under6);
    }];
    agreeButton.layer.cornerRadius = 10;
    
    dissAgree = [UIButton buttonWithType:UIButtonTypeCustom];
    dissAgree.tag = 900+2;
    [dissAgree setTitle:@"我不同意" forState:UIControlStateNormal];
    dissAgree.titleLabel.font = FONT(16);
    dissAgree.backgroundColor = [UIColor redColor];
    [dissAgree addTarget:self action:@selector(approval:) forControlEvents:UIControlEventTouchUpInside];
    [under6 addSubview:dissAgree];
    [dissAgree mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(agreeButton.mas_bottom).offset(10);
        make.width.mas_equalTo(200*FitSize);
        make.height.mas_equalTo(30*FitSize).priorityLow();
        make.centerX.equalTo(under6);
    }];
    dissAgree.layer.cornerRadius = 10;
    
    [under6 mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(dissAgree.mas_bottom).offset(10);
    }];
    
    
    [container mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(under6.mas_bottom).offset(30);
    }];
}

//展示公文内容
- (void)showContent{
    showContentButton.hidden = YES;
    [webViewZQX loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.dataFromAFNet[@"DocBody"]]]];

}

- (void)approval:(UIButton *)sender{
    NSString *isAgree = @"";
    if ( sender.tag - 900 == 1) {
        isAgree = @"1";
    }else{
        isAgree = @"-1";
    }
    NSString *ashx = @"/Server/FlowsHandler.ashx";
    NSDictionary *dic = @{@"act":@"apflow",@"fid":self.dataFromAFNet[@"ID"],@"apstatus":isAgree,@"apinfo":myOpinion.text,@"Sid":self.dataFromAFNet[@"CurrentStepID"],@"uname":[UserInfo getUserName],@"upwd":[UserInfo getPassWord]};
    [httpPostRequest getDataByPostAshx:ashx and:dic withFinishBlock:^(id model, NSError *error) {
        if (error == nil) {
            NSString *code = [NSString stringWithFormat:@"%@",[model objectForKey:@"code"]];
            if ([code isEqualToString:@"0"]) {
                [self getData];
                myOpinion.text = @"";
            }else{
                [XHToast showCenterWithText:@"审批意见不能为空!"];
                [self getData];
            }
        }else{
            NSLog(@"错误%@",error);
            [XHToast showBottomWithText:@"请求失败"];
        }
    }];
}



//文本开始编辑
- (void)textFieldDidBeginEditing:(UITextField *)textField{
    [scrollView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-222);
    }];
    [scrollView setContentOffset:CGPointMake(0, scrollView.contentSize.height-222)];
    tapGecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(textViewEnd)];
    [scrollView addGestureRecognizer:tapGecognizer];
    
    
}

- (void)textViewDidEndEditing:(UITextView *)textView{
    [self textViewEnd];
    
}
//自定义方法 添加手势 键盘收回 滑动控件滑到最下面 去除手势
- (void)textViewEnd{
    [myOpinion resignFirstResponder];
    [scrollView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(0);
    }];
    [scrollView removeGestureRecognizer:tapGecognizer];
}

#pragma tableViewDelgate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return self.otherConteDataSource.count;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return [[self.otherConteDataSource objectAtIndex:section] count];
}
- (nullable NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{

    if (section == 0) {
        return @"额外内容";
    }else{
        return [NSString stringWithFormat:@""];
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *CellID = @"CellID";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.textLabel.text = self.otherConteDataSource[indexPath.section][indexPath.row][@"clmValue"];
    
    return cell;
    
}




#pragma webViewDelegate
/**
 *  webView开始加载
 */
- (void)webViewDidStartLoad:(UIWebView *)webView{
    [LBProgressHUD showHUDto:webView animated:YES];
}
/**
 *  webView结束加载
 */
- (void)webViewDidFinishLoad:(UIWebView *)webView{
    [LBProgressHUD hideAllHUDsForView:webView animated:YES];
    [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.zoom=1.6"];
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '190%'"];
    CGSize actualSize = [webView sizeThatFits:CGSizeZero];
    CGRect newFrame = webView.frame;
    newFrame.size.height = actualSize.height*1.6;
    NSLog(@"浏览器高度:%f",newFrame.size.height);
    webView.frame = newFrame;
    
    NSLog(@"浏览器尺寸：%@",NSStringFromCGRect(newFrame));
    [under2 mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(webView.frame.size.height+30);
    }];
    [under3 mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(under2.mas_bottom).offset(20);
    }];
    
}

@end
